﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = ConfigurationManager.AppSettings["AppOwner"] + " " + ConfigurationManager.AppSettings["AppShortName"];
        lblHeading1.Text = ConfigurationManager.AppSettings["AppOwner"];
        lblHeading2.Text = ConfigurationManager.AppSettings["AppName"];
        txtUsername.Focus();
        form1.DefaultButton = "btnSubmit";

    }
    protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
    {
        if (Page.IsValid)
        {
            ManageUser objUser = new ManageUser();
            if (!objUser.isValidUser(txtUsername.Text.Trim(),
                                     txtPassword.Text.Trim()))
            {
                lblMsg.Text = "Sorry, your Username/Password do not match.";
                lblMsg.Visible = true;
            }
            else
            {
                Session["UserInfo"] = objUser;
                if (objUser.UserLevel > 1) //Not a Student
                        Response.Redirect("~/admin/Default.aspx");
                else
                    Response.Redirect("Main.aspx");
            }
        }
    }
    
}
